﻿<!DOCTYPE html>
<!--试题管理列表-->
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="/static/js/common.js"></script>
    <style>
        .el-table__body-wrapper table tbody tr td {
            text-align: center;
        }

        .el-table .cell {
            text-align: center;
        }
    </style>

</head>

<body>
    <div id="app" v-cloak class="popupW50">
        <el-row>


            <el-col :span="24">
                <el-form ref="form" :inline="true" label-position="right" label-width="100px" :model="formInline"
                    class="demo-form-inline" style="margin-bottom: 15px;">

                    <el-row>
                        <el-col class="head-tool">
                            
<div class="new_title fl"><strong><img src="/static/images/icon1.png" />试题管理列表</strong>
                            </div>
                            <span>

                                <btn :text="col.btnAdd" linetype="3" @click="UserInput('tj')"></btn>

                                <btn-export-list url="/api/CBS_Questions/Export" :forminline="this.formInline" linetype="3">
                                </btn-export-list>
                                <btn :text="col.btnDelete" linetype="4" @click="onDelete"></btn>
                            </span>
                        </el-col>
                    </el-row>
                </el-form>
                <!--<el-col :span="5">
                    <div class="tree_lay">
                        <h4 class="title clearfix"><strong>区域</strong></h4>
                        <el-tree :data="TreeData" :props="defaultProps" @node-click="handleNodeClick">
                            <span slot-scope="scope">
                                <span>
                                    <i :class="scope.data.icon"></i>
                                    <template>
                                        <span v-if="scope.data.icon == 'tree-open'"
                                            style="color:#12489e">{{ scope.node.label }}</span>
                                        <span v-else-if="scope.data.icon == 'tree-close'"
                                            style="color: #12489e">{{ scope.node.label }}</span>
                                        <span v-else>{{ scope.node.label }}</span>
                                    </template>
                                </span>
                        </el-tree>
                    </div>
                </el-col>-->
                <el-col :span="24">
                    <el-table stripe ref="table" :data="ListItem.tableData" :height="ListItem.tableHeight" border
                        @selection-change="handleSelectionChange" row-style="height:10px" style="width: 100%">
                        <el-table-column type="selection" align="center" width="55">
                        </el-table-column>
                        <el-table-column type="index" :label="ContractorDirectory.SerialNumber" :index="indexMethod"
                            width="50" show-overflow-tooltip="true"></el-table-column>
                        <el-table-column prop="testQuestionsContent" :label="TestQuestions.TestQuestionsContent"
                            show-overflow-tooltip="true" width="360">
                        </el-table-column>
                        <el-table-column prop="testQuestionsType" :label="TestQuestions.TestQuestionsType">
                        </el-table-column>
                        <el-table-column prop="cbS_Course.trainingCoursewareName" :label="TestQuestions.CoursewareType" width="150">
                        </el-table-column>
                        <el-table-column prop="degreeOfDifficulty" :label="TestQuestions.DegreeOfDifficulty">
                        </el-table-column>
                        <el-table-column prop="numberOfOptions" :label="TestQuestions.NumberOfOptions">
                        </el-table-column>
                        <el-table-column prop="mark01" :label="TestQuestions.Answer" min-width="100">
                        </el-table-column>
                        <el-table-column prop="createUserText" :label="TestQuestions.editor" min-width="120">
                        </el-table-column>
                        <el-table-column prop="createTime" :label="TestQuestions.editorTime" :formatter="myformatDate"
                            show-overflow-tooltip="true" min-width="150">
                        </el-table-column>
                        <el-table-column width="53" prop="update" :label="col.btnUpdate" fixed="right">
                            <template slot-scope="scope">
                                <button type="button" class="elst-bt-xg" @click=UserInput('xg',scope.row.id)>
                                    <i class="el-icon-edit"></i>
                                </button>
                            </template>
                        </el-table-column>
                    </el-table>
                    <el-row type="flex" justify="end">
                        <el-pagination ref="page" @size-change="handleSizeChange" @current-change="handleCurrentChange"
                            :current-page="ListItem.currentPage" :page-sizes="ListItem.pagesizes"
                            :page-size="ListItem.pagesize" :layout="ListItem.layout" :total="ListItem.total">
                        </el-pagination>

                    </el-row>
                </el-col>

            </el-col>
        </el-row>
        <el-dialog title="试题管理" :visible.sync="ListItem.dialogVisible" @close='closeDialog' width="90%" height="100%"
            top="10vh" fullscreen="true"  style="height:100% !important;" >
            <iframe ref="iframe" :src="ListItem.InputUrl" style="height:100% !important;width:100%" frameborder="0"></iframe>
        </el-dialog>
    </div>
    <script type="text/javascript">
        //获取分页数据
        function GetPageData1(mythis, currentIndex, url) {
            var currObj = mythis;
                myAjax("post", mythis, url, {
                    model: { cbSCourseId: currObj.courseClassId}, offset: 0, limit: 100 }, function (response) {
                    //console.log(response);
                    if (response.data.pageData.length == 0) {
                        currObj.ListItem.tableData = [];
                        currObj.ListItem.total = 0;
                    } else {
                        currObj.ListItem.tableData = response.data.pageData;
                        currObj.ListItem.total = response.data.pageData.length;
                    }
                });
            
        }
        app = new Vue({
            el: '#app',
            data: function () {
                return {
                    courseClassId:'',
                    TreeData: [],
                    //mydata: TestQuestionsTree,
                    defaultProps: {
                        children: 'children',
                        label: 'label'
                    },
                    RiskLevel: [],
                    ListItem: ListItem,
                    formInline: {
                        model: {
                            TestQuestionsContent: '',//"试题内容"
                            TestQuestionsType: '', //试题类型
                            DegreeOfDifficulty: '',//难易程度
                            NumberOfOptions: '',//选项个数
                            Answer: '',//答案
                            editor: '',
                            editorTime: '',
                            CoursewareType: '',//课件类型
                            CoursewareID: '',//课件类型ID
                            OptionsList: [],//选项
                            TreeNode: ''
                        },
                        offset: 0,
                        limit: 10
                    }
                }
            }, created: function () {
                var currApp = this;
                window.onresize = function () {
                    currApp.ListItem.tableHeight = window.innerHeight -
                        currApp.$refs.table.$el.offsetTop - 60;
                    if (currApp.ListItem.tableHeight < 112) {
                        currApp.ListItem.tableHeight = 112;
                    }
                }
            },
            mounted: function () {
                this.courseClassId = getUrlParam("courseClassId");
                //初始化数据
                this.GetPageData(1);
                
                //列表高度自适应
                tablehigh(this);
                //this.TreeData = fn(this.mydata, "0");
            },
            methods: {
                //解決edge下select bug
                visibleChange: function (isVisible) {
                    visibleChange(isVisible)
                },
                indexMethod: function (index) {
                    return (this.ListItem.currentPage - 1) * this.ListItem.pagesize + index + 1;
                },

                handleNodeClick: function (data) {
                    if (!data.children) {
                        this.formInline.model.TreeNode = data.id
                        onSubmit(this);
                    }
                    else {
                        if (data.icon == "tree-open") {
                            data.icon = "tree-close"
                        } else (
                            data.icon = "tree-open"
                        )
                    }
                },
                closeDialog: function () { closeDialog(this); },
                //删除方法
                onDelete: function () { onDelete(this, '/api/CBS_Questions/DeleteMuti'); },
                //列表选择触发
                handleSelectionChange: function (val) { handleSelectionChange(this, val); },
                //Dialog展示
                UserInput: function (val, id) { DialogShow(this, val, "TestQuestionsManagementInput.html", id, "&CBSCourseId=" + this.courseClassId); },
                //获取分页数据
                GetPageData: function (currentIndex) { GetPageData1(this, currentIndex, '/api/CBS_Questions/GetList') },
                //查询方法
                onSubmit: function () { onSubmit(this); },
                //pagesize改变 触发方法
                handleSizeChange: function (val) { handleSizeChange(this, val); },
                //跳页触发方法
                handleCurrentChange: function (val) { handleCurrentChange(this, val); }
            }
        });

    </script>
</body>

</html>